/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dijkstra;

/**
 *
 * @author luisorozco
 */
public class Node<T>
{
    /**
     * The data value stored in this node.
     */
    protected T data; // value stored in this element
    protected String code;
    /**
     * Reference to the next node in the list.
     */
    protected Node<T> nextElement; // ref to next

    /**
     * Construct a singly linked list element.
     *
     * @pre v is a value, next is a reference to remainder of list
     * @post an element is constructed as the new head of list
     * @param v The value to be referenced by this element.
     * @param next A reference to the next value in the list.
     */
    public Node(String code, T data)
    {
        this.data = data;
        this.code = code;
    }

    /**
     * Constructs a node not associated with
     * any list.  next reference is set to null.
     *
     * @post constructs a new tail of a list with value v
     * 
     * @param v The value to be inserted into the node.
     */
    public Node(String code )
    {
        this.code=code;
    }

    /**
     * @post returns reference to next value in list
     * 
     */
    public Node<T> next()
    {
        return nextElement;
    }

    /**
     * Update the next element.
     *
     * @post sets reference to new next value
     * 
     * @param next The new value of the next element reference.
     */
    public void seData(T data)
    {
        this.data = data;
    }
    
     public void setCode(String code)
    {
        this.code=code;
    }

   
     
    /**
     * Fetch the value associated with this element.
     *
     * @post returns value associated with this element
     * 
     * @return Reference to the value stored within this element.
     */
    public T value()
    {
        return data;
    }
    
    public String getCode(){
        
        return code;
    }

    
    public T getData(){
        
        return data;
    }
    /**
     * Set the value associated with this element.
     *
     * @post sets value associated with this element
     * 
     * @param value The new value to be associated with this element.
     */
    public void setValue(T value)
    {
        data = value;
    }

    /**
     * Construct a string representation of element.
     *
     * @post returns string representation of element
     * 
     * @return The string representing element.
     */
    public String toString()
    {
        return "<Node: "+ code + "_" + data.toString() + ">";
    }
}
